﻿#ifndef __TEST__MEM__POOL__H
#define __TEST__MEM__POOL__H

#include <stdlib.h>

#define __OBJ_NUM 200000

struct stObj
{
	stObj()
	{
		addr = NULL;
		size = 0;
	}
	void* addr;			/// 指针
	size_t size;		/// 内存大小
};

class TestMemPool
{
public:
	enum
	{
		__TYPE_RAND = 0,
		__TYPE_EVERY,
	};

public:
	TestMemPool();
	~TestMemPool();

	/// 分配空间
	void Alloc(int type, bool pool = true);
	void Alloc2(int type, bool pool = true);

	/// 释放空间
	void Dealloc(int type, bool pool = true);
	void Dealloc2(int type, bool pool = true);

	/// 暴力测试
	void ViolenceTest(size_t n, int type = __TYPE_RAND, bool pool = true);

	/// 重置内存分配大小
	void ResetSize();

private:
	stObj *m_obj;		/// 内存指针
	stObj *m_obj2;		/// 内存指针2
};

#endif	/// __TEST__MEM__POOL__H